package com.ymatou.iapi.quickturnover.testcase;

import org.apache.poi.ss.formula.functions.Code;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.quickturnover.parameter.GetXloboOrdersCountReqBean;
import com.ymatou.iapi.quickturnover.service.GetXloboOrdersCountReqCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.constant.ECode;
/**
*获取买手90天订单量(贝海发货且确认收货)接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetXloboOrdersCountReq{
	private static GetXloboOrdersCountReqBean getxloboorderscountreqBean;
	private static GetXloboOrdersCountReqCall getxloboorderscountreqCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取买手90天订单量(贝海发货且确认收货)接口");
	}

	@Before
	public void caseUp() {
		getxloboorderscountreqBean=new GetXloboOrdersCountReqBean();
		getxloboorderscountreqCall=new GetXloboOrdersCountReqCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getxloboorderscountreqCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetXloboOrdersCountReq_001() {
		Logger.start(true,"获取买手90天订单量(贝海发货且确认收货)");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			getxloboorderscountreqBean.setSellerId(sellerId);
			getxloboorderscountreqCall.setData(getxloboorderscountreqBean);
			getxloboorderscountreqCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, getxloboorderscountreqCall.getString("code"), "验证code");
			//Logger.verifyEquals(0, getxloboorderscountreqCall.getData().getInt("receivedOrdersCount"), "验证receivedOrdersCount");
			Logger.verifyEquals(true, getxloboorderscountreqCall.getData().getBoolean("success"), "验证success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetXloboOrdersCountReq_002() {
		Logger.start(true,"sellerid 不存在");
		try {
			int sellerId =1234;
			getxloboorderscountreqBean.setSellerId(sellerId);
			getxloboorderscountreqCall.setData(getxloboorderscountreqBean);
			getxloboorderscountreqCall.callService();		
			
			Logger.verifyEquals(ECode.SUCCESS, getxloboorderscountreqCall.getString("code"), "验证code");
			Logger.verifyEquals(0, getxloboorderscountreqCall.getData().getInt("receivedOrdersCount"), "验证receivedOrdersCount");
			Logger.verifyEquals(true, getxloboorderscountreqCall.getData().getBoolean("success"), "验证success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetXloboOrdersCountReq_003() {
		Logger.start(true,"sellerid 为null");
		try {
			//getxloboorderscountreqBean.setSellerId(sellerId);
			getxloboorderscountreqCall.setData(getxloboorderscountreqBean);
			getxloboorderscountreqCall.callService();		
			
			Logger.verifyEquals(ECode.ERROR400, getxloboorderscountreqCall.getString("code"), "验证code");
			Logger.verifyEquals("sellerId:卖家ID不能为0", getxloboorderscountreqCall.getString("msg"), "验证msg");
			Logger.verifyEquals(0, getxloboorderscountreqCall.getData().getInt("receivedOrdersCount"), "验证receivedOrdersCount");
			Logger.verifyEquals(false, getxloboorderscountreqCall.getData().getBoolean("success"), "验证success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}